local skel = fk.CreateSkill {
  name = "efengqi__niepan",
}

Fk:loadTranslationTable{
  ["efengqi__niepan"] = "涅槃",
  [":efengqi__niepan"] = "结束阶段，你可以受到1点火焰伤害；你因火焰伤害进入濒死状态时，回复体力和手牌至上限。",
  ["#efengqi__niepan-invoke"] = "涅槃:你可以受到1点火焰伤害",

  ["$efengqi__niepan1"] = "凤雏岂能消亡？",
  ["$efengqi__niepan2"] = "浴火重生！",
}

skel:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and target == player then
      return player.phase == Player.Finish
    end
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#efengqi__niepan-invoke" })
  end,
  on_use = function (self, event, target, player, data)
    player.room:damage { from = player, to = player, damage = 1, skillName = skel.name, damageType = fk.FireDamage }
  end,
})

skel:addEffect(fk.EnterDying, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and target == player then
      return data.damage and data.damage.damageType == fk.FireDamage
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    player.room:recover { num = player.maxHp - player.hp, skillName = skel.name, who = player, recoverBy = player }
    if player:isAlive() then
      local x = player.maxHp - player:getHandcardNum()
      if x > 0 then
        player:drawCards(x, skel.name)
      end
    end
  end,
})

return skel
